package com.zy.bootdemo.controller;

import com.zy.bootdemo.entity.RoomEntity;
import com.zy.bootdemo.entity.TypeEntity;
import com.zy.bootdemo.service.RoomService;
import com.zy.bootdemo.util.JSONUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/room")
public class RoomController {
    @Resource
    RoomService roomService;
    @GetMapping("/selectAll")
    public String selectAll(){
        return JSONUtil.getJson(roomService.selectAll());
    }

    @PostMapping("/insertOne")
    public boolean insertOne(String rNum,int rType){
        return roomService.insertOne(rNum,rType);
    }
    @GetMapping("/selectOne")

    public String selectOne(int id){
        return roomService.selectOne(id);
    }
    @PostMapping("/delOne")
    public boolean delOne(Integer id){
        return roomService.delOne(id);
    }
    @GetMapping("/selectByType")
    public  String selectByType(Integer id){
        return JSONUtil.getJson(roomService.selectByType(id));
    }
}
